#include <linux/init.h>
#include <linux/module.h>
#include <linux/fs.h>
#include <linux/cdev.h>
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/moduleparam.h>
#include <linux/uaccess.h>

#define SCRULL_QUANTUM 4000
#define SCRULL_QSET 1000

struct scrull_qset {
    void **data;
    struct scrull_qset *next;
};

struct scrull_dev {
    struct scrull_qset *data;
    int quantum;
    int qset;
    unsigned long size;
    unsigned int access_key;
    struct semaphore sem;
    struct cdev cdev;
};

int scrull_open(struct inode *inode, struct file *filp);
int scrull_release(struct inode *inode, struct file *filp);
int scrull_trim(struct scrull_dev *dev);
int scrull_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long param);
ssize_t scrull_read(struct file *filp, char __user *buf, size_t count, loff_t *f_pos);
ssize_t scrull_write(struct file *filp, const char __user *buf, size_t count, loff_t *f_pos);
loff_t scrull_llseek(struct file *filp, loff_t offset, int whence);
struct scrull_qset *scrull_follow(struct scrull_dev *dev, int item);
